<!-- INCLUDE ../include/title.html -->
<body>

<div class="ch-container">
    <div class="row">
        <input type="hidden" id="ChannelID" value="{ChannelID}" />
        <div id="content" >
            <div class="box-content">


                        <table class="table table-striped" style="width:840px">
                            <thead>
                                <tr role="row">
                                    <th>任务名</th>
                                    <th>开始时间</th>
                                    <th>结束时间</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody >
                                <!-- BEGIN ret -->
                                <tr >
                                    <td>
                                        <a  href="#" hrefto="index.php?do=Record/record_add&TaskID={TaskID}&ClassID={ClassID}" class="recordlist">
                                            {TaskName}
                                        </a>

                                    </td>
                                    <td>{BeginTime}</td>
                                    <td>{EndTime}</td>
                                    <td class="alltashids" id="status_{TaskID}">
                                        <!-- IF TaskStatus="0" -->
                                        <span class="label label-success">
                                            {TaskStatusShow}
                                        </span>
                                        <!-- ELSEIF TaskStatus="1" -->
                                        <span class="label-default label">{TaskStatusShow}</span>
                                        <!-- ELSEIF TaskStatus="2" -->
                                        <span class="label label-info">{TaskStatusShow}</span>
                                        <!-- ELSEIF TaskStatus="99" -->
                                        <span class="label label-warning">{TaskStatusShow}</span>
                                        <!-- ELSE -->
                                        <span class="label label-success">
                                        </span>
                                        <!-- ENDIF -->
                                    </td>
                                    <td class="center ">
                                        <a  href="#" hrefto="index.php?do=Record/record_add&TaskID={TaskID}&ClassID={ClassID}" class="btn btn-info recordlist">
                                            <i class="glyphicon glyphicon-edit icon-white"></i>
                                            编辑
                                        </a>
                                        <a href="#" onclick="deletedata('RecordTask',{TaskID})" class="btn btn-danger">
                                            <i class="glyphicon glyphicon-trash icon-white"></i>
                                            删除
                                        </a>
                                    </td>
                                </tr>
                                <!-- END ret -->
                            </tbody>
                    </table>
            </div>

        </div>
    </div>
</div><!--/.fluid-container-->

<!-- INCLUDE ../include/bottom.html -->

<script type="text/javascript">
$(document).ready(function() {
    $(".recordlist").bind("click",function(){
        parent.removeBox($(this).attr("hrefto"));
    })

    setInterval(getStatus,5000);
    //getStatus();
} );


function getStatus(){
    //var Taskid = [];
    /*$(".alltashids").each(function(){
        var id = $(this).attr("id").replace("status_",'');
        Taskid.push(id);
    })*/
    
    var ChannelID = $("#ChannelID").val();

    $.get("./index.php?do=index/Ajax&action=getRecordStatus&ChannelID="+ChannelID,function(data){
        //console.log(data);
        data = eval("("+data+")");
        for (var i = 0; i < data.length; i++) {
              //console.log(data[i]['TaskID']);
              var TaskID = data[i]['TaskID'];
              switch(parseInt(data[i]['TaskStatus'])) {
                    case 0 :
                        $("#status_"+TaskID).find("span").attr("class",'label label-success');
                        break;
                    case 1 :
                        $("#status_"+TaskID).find("span").attr("class",'label-default label ');
                        break;
                    case 2 :
                        $("#status_"+TaskID).find("span").attr("class",'label label-info');
                        break;
                    case 99 :
                        $("#status_"+TaskID).find("span").attr("class",'label label-warning');
                        break;
              }
             $("#status_"+TaskID).find("span").html(data[i]['TaskStatusShow']); 

          };  
        
        //window.location.href="./index.php?do=index/login";
    })
}



</script>

</body>
